package top.haijunit.common.response.data;

import lombok.Getter;

/**
 * 自定义服务异常
 *
 * @author zhanghaijun
 * @date 2024/6/7 09:20
 * @description [一句话描述该类的功能]
 */
@Getter
public class ExceptionServer extends RuntimeException implements ExceptionSupport {

    private final Integer code;
    private final String message;

    public ExceptionServer(Integer code, String message, Throwable e) {
        super(String.format("server exception, code: %s, message: %s", code, message), e);
        this.code = code;
        this.message = message;
    }

    public ExceptionServer(Integer code, String message) {
        super(String.format("failure: %s, failure is %s%n", code, message));
        this.code = code;
        this.message = message;
    }

    /** 自定义异常不需要堆栈，提高性能 */
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
